export default function useReportCell() {
  const inputIndex = ref(-1)

  function clickCallback(
    evt: Event,
    callback?: () => void,
  ) {
    if (evt.target) {
      (evt.target as HTMLInputElement).select()

      inputIndex.value = Number(
        (evt.target as HTMLInputElement).dataset.inputIndex,
      )

      callback?.()
    }
  }

  function initInputIndex() {
    const inputs = document.querySelectorAll('.input-cell input')
    inputs.forEach((input, index) => {
      (input as HTMLElement).dataset.inputIndex = `${index}`
    })
  }

  return {
    inputIndex,

    clickCallback,
    initInputIndex,
  }
}
